#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
class QAction;
class QToolButton;
class QRadioButton;
class QComboBox;
class QCheckBox;
class QTextEdit;
class QToolBar;
class QToolBox;
class QTabWidget;
class QDockWidget;
class QStackedWidget;
class QSqlError;
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void onLoginMode();
    void onConnDevice();
    void onScanDevice();
    void onConnDatabase();
    void onLoadFormatFile();
    void onEditLogicFile();
    void onAbout();

    void onDeviceIpAddrChanged(QString ipAddr);
    void showPropertyPlane();
    void showLogWindow();
private:
    void showError(const QSqlError &err);
    void createActions();
    void createToolbars();
    void createPropertyPlane();
    void createLogTabWidget();
    void createWorkSpace();
    void showMessage(QString const& msg);
    QMenu *createViewMenu();

    // state
    bool isLoginMode;
    bool hasConnDevice;
    bool isScanning;

    // file
    QAction *loginModeAction;
    QAction *connDeviceAction;
    QAction *scanDeviceAction;

    // edit
    QAction *connDatabaseAction;
    QAction *loadFormatFileAction;
    QAction *editLogicFileAction;

    // system
    QToolButton *viewMenu;
    QAction *aboutAction;
    QAction *exitAction;

    // property plane
    QToolButton *deviceStateImage;
    QComboBox *deviceNoComboBox;
    QStringList deviceIpAddrList;
    QComboBox *deviceIpAddrComboBox;
    QComboBox *scanSpeedComboBox;
    QComboBox *cardIntervalComboBox;

    QRadioButton *exam_room_mode_radio_btn;
    QRadioButton *insert_mode_radio_btn;

    QToolBar *fileToolBar;
    QToolBar *editToolBar;
    QToolBar *systemToolBar;

    QToolBox *propertyPlane;
    QTabWidget *logTabWidget;
    QStackedWidget *workspace;

    QDockWidget* propertyDockWidget;
    QDockWidget* logDockWidget;
};
#endif // MAINWINDOW_H
